// custom-tab-bar/index.js
import {
  ComponentWithStore
} from 'mobx-miniprogram-bindings' //引入创建绑定实例
import {
  store
} from '../stores/store' // 引入仓库store

ComponentWithStore({

  options: {
    "styleIsolation": "shared"
  },

  storeBindings: {
    store: store,
    fields: ["activeTabBar"],
    actions: ["updateActive"]
  },




  data: {

    list: [{
        "pagePath": "/pages/index/index",
        "text": "首页",
        "iconPath": "/assets/tabbar/home_off.png",
        "selectedIconPath": "/assets/tabbar/home.png",

      },
      {
        "pagePath": "/pages/schedule/schedule",
        "text": "进度",
        "iconPath": "/assets/tabbar/progress_off.png",
        "selectedIconPath": "/assets/tabbar/progress.png"
      },
      {
        "pagePath": "/pages/my/my",
        "text": "我的",
        "iconPath": "/assets/tabbar/my_off.png",
        "selectedIconPath": "/assets/tabbar/my.png",
      }
    ]
  },

  methods: {
    onChange(event) {
      // event.detail 的值为当前选中项的索引 
      this.updateActive(event.detail)
     // console.log(event.detail)
     
      wx.switchTab({
        url: String(this.data.list[event.detail].pagePath),
      })
    }
  },

})